<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>02计算器</title>
</head>

<body>
    <input type="text" id="i1"><br>
    <input type="text" id="i2"><br>
    <button onclick="sum()">加</button>
    <button onclick="sub()">减</button>
    <button onclick="mul()">乘</button>
    <button onclick="div()">除</button>
    <script>
        function sum() {
            let num1 = document.getElementById("i1").value;
            let num2 = document.getElementById("i2").value;
            console.log(Number(num1) + Number(num2));
        }
        function sub() {
            let num1 = document.getElementById("i1").value;
            let num2 = document.getElementById("i2").value;
            console.log(Number(num1) - Number(num2));
        }
        function mul() {
            let num1 = document.getElementById("i1").value;
            let num2 = document.getElementById("i2").value;
            console.log(Number(num1) * Number(num2));
        };
        function div() {
            let num1 = document.getElementById("i1").value;
            let num2 = document.getElementById("i2").value;
            console.log(Number(num1) / Number(num2));
        }
    </script>
</body>

</html>